package com.komunide.zap.authentification;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class Configuration extends Activity implements OnClickListener {
	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        
        
        TextView courrielView = (TextView) findViewById(R.id.courriel);
    	TextView motDePasseView = (TextView) findViewById(R.id.motDePasse);
    	TextView bouton = (TextView) findViewById(R.id.enregistrer);

    	bouton.setOnClickListener(this);
    	
    	SharedPreferences preferences = getPreferences(MODE_PRIVATE);
    	String courriel = preferences.getString("courriel", "");
    	String motDePasse = preferences.getString("motDePasse", "");
   
    	courrielView.setText(courriel);
    	motDePasseView.setText(motDePasse);

        
    }
    
    public void onClick(View v){
    	TextView courrielView = (TextView) findViewById(R.id.courriel);
    	TextView motDePasseView = (TextView) findViewById(R.id.motDePasse);
    	String courriel = courrielView.getText().toString();
    	String motDePasse = motDePasseView.getText().toString();
    	
    	
    	SharedPreferences preferences = getPreferences(MODE_PRIVATE);
    	Editor editor = preferences.edit();
    	editor.putString("courriel", courriel);
    	editor.putString("motDePasse", motDePasse);
    	editor.commit();
    }
}